package Test.jsp.common;

import java.io.File;
import java.io.FileWriter;

public class JSPHeaderTemp {

	public static void jSPHeaderTest() throws  Exception{
		String rn = "\r\n";
		
		String src = 
		
		
		"<%@ page language=\"java\"  import=\"java.util.*\" pageEncoding=\"UTF-8\"%>" + rn + 
		"<%@ taglib uri=\"http://java.sun.com/jsp/jstl/core\" prefix=\"c\"%>" + rn + 
		"<%@ taglib prefix=\"form\" uri=\"http://www.springframework.org/tags/form\" %>" + rn + 
		"<%@ taglib prefix=\"fmt\" uri=\"http://java.sun.com/jsp/jstl/fmt\" %>" + rn + 
		"<%@ taglib prefix=\"fn\" uri=\"http://java.sun.com/jsp/jstl/functions\" %>" + rn + 
		"<%" + rn + 
		"String path = request.getContextPath();" + rn + 
		"String basePath = request.getScheme()+\"://\"+request.getServerName()+\":\"+request.getServerPort()+path+\"/\";" + rn + 
		"%>" + rn + 

		"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">" + rn + 
		"<html>" + rn + 
		"  <head>" + rn + 
		"    <base href=\"<%=basePath%>\">" + rn + 
		    
		"    <title>headerFrame</title>" + rn + 
		"  </head>" + rn + 

		"  <body bgcolor=\"#046DAC\">" + rn + 
		"     <h1>welcome to auto freemarker system </h1>" + rn + 
		"  </body>" + rn + 
		
		rn + 
		"</html>" + rn + 
		
		rn;
		
		String path = System.getProperty("user.dir")+"/WebRoot/back/jsp/";
		String fileName = System.getProperty("user.dir")+"/WebRoot/back/jsp/header.jsp";
		File fpath = new File(path);
		if (!fpath.exists()) {
		   fpath.mkdirs();
	    }
		File f = new File(fileName);
		FileWriter fw = new FileWriter(f);
		fw.write(src);
		fw.flush();
		fw.close();
 }	
}
